From 029b23523440b7a4b8f9943cc1679fceec11fb87 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Sat, 19 Jan 2002 07:52:52 +0000 Subject: [PATCH] Catch invalid borders, and warn. Sat Jan 19 02:45:17 2002 Owen Taylor * src/pixbuf-render.c (theme_pixbuf_compute_hints): Catch invalid borders, and warn. --- modules/engines/pixbuf/ChangeLog | 5 +++++ modules/engines/pixbuf/pixbuf-render.c | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/modules/engines/pixbuf/ChangeLog b/modules/engines/pixbuf/ChangeLog index 72c1bba1da..e33e9cc81a 100644 --- a/modules/engines/pixbuf/ChangeLog +++ b/modules/engines/pixbuf/ChangeLog @@ -1,3 +1,8 @@ +Sat Jan 19 02:45:17 2002 Owen Taylor + + * src/pixbuf-render.c (theme_pixbuf_compute_hints): Catch + invalid borders, and warn. + Sat Jan 19 00:32:14 2002 Owen Taylor * examples/*: Add an extrodinarily ugly example. diff --git a/modules/engines/pixbuf/pixbuf-render.c b/modules/engines/pixbuf/pixbuf-render.c index d50d4c210d..08201f330f 100644 --- a/modules/engines/pixbuf/pixbuf-render.c +++ b/modules/engines/pixbuf/pixbuf-render.c @@ -373,6 +373,19 @@ theme_pixbuf_compute_hints (ThemePixbuf *theme_pb) int i, j; gint width = gdk_pixbuf_get_width (theme_pb->pixbuf); gint height = gdk_pixbuf_get_height (theme_pb->pixbuf); + + if (theme_pb->border_left + theme_pb->border_right >= width || + theme_pb->border_top + theme_pb->border_bottom >= height) + { + g_warning ("Invalid borders specified for theme pixmap:\n" + " %s,\n" + "there must be at least one pixel not in the border both horizontally\n" + "and vertically", theme_pb->filename); + if (theme_pb->border_left + theme_pb->border_right >= width) + theme_pb->border_left = theme_pb->border_right = width / 2 + 1 - (width % 2); + if (theme_pb->border_bottom + theme_pb->border_top >= height) + theme_pb->border_bottom = theme_pb->border_top = height / 2 + 1 - (height % 2); + } for (i = 0; i < 3; i++) { -- 2.30.2